package com.xiangban.controller;

import com.xiangban.model.TSystem;
import com.xiangban.model.dto.SystemDto;
import com.xiangban.model.res.ApiResult;
import com.xiangban.service.SystemService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cloud.context.config.annotation.RefreshScope;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.HashMap;
import java.util.List;

@RestController
@RefreshScope
@RequestMapping("/system")
public class SystemController {
    @Autowired
    private SystemService systemService;
    @RequestMapping("/allSystemConfig")
    public ApiResult<Object> allSystemConfig(){
        List<SystemDto> res = systemService.allSystemConfig();
        return ApiResult.newSuccess(res);

    }

    @RequestMapping("/getSystemConfigByAccessId")
    public ApiResult<Object> getSystemConfigByAccessId(@RequestBody TSystem system){
        SystemDto res = systemService.getSystemConfigByAccessId(system);
        return ApiResult.newSuccess(res);

    }

    @RequestMapping("/selectSystemByAccessId")
    @ApiOperation("根据access_id查询system")
    public ApiResult<Object> selectSystemByAccessId(@RequestBody TSystem tSystem){
        return ApiResult.newSuccess(systemService.selectSystemByAccessId(tSystem));

    }

    @RequestMapping("/getSystemByAppId")
    @ApiOperation("根据appid查询system")
    public ApiResult<Object> getSystemByAppId(@RequestParam String appid){
        return ApiResult.newSuccess(systemService.getSystemByAppId(appid));

    }
}
